Arizona Indigenous Tribal Water Rights

DataViz
Tables
Indigenous Rights
#2024PositTableContest
Examination of US federally recognized indigenous tribes in AZ, with respect to their water rights
Author
Affiliation

Dr. Greg Chism

School of Information, University of Arizona

0 - Set up

Packages Installed
if(!require(pacman))
  install.packages("pacman")

pacman::p_load(cowplot,
               here,
               htmltools,
               lwgeom,
               tidyverse,
               tigris,
               sf,
               ggtext,
               ggrepel,
               ggiraph,
               glue,
               readxl,
               janitor,
               reactable,     # for HTML tables
               reactablefmtr, # for easier formatting reactable tables
               scales,
               patchwork,
               usmap)


pacman::p_load_gh("AllanCameron/geomtextpath")

# Options to use tigris datasets with sf
options(tigris_use_cache = TRUE, tigris_class = "sf")

Setting the default theme ggplot and output options for the chunk.

Theme Settings
# setting theme for ggplot2
ggplot2::theme_set(cowplot::theme_map())

# setting figure parameters for knitr
knitr::opts_chunk$set(
  fig.width = 8,        # 8" width
  fig.asp = 0.65,       # the golden ratio
  fig.retina = 1,       # dpi multiplier for displaying HTML output on retina
  fig.align = "center", # center align figures
  dpi = 350,            # higher dpi, sharper image
  message = FALSE
)

2 - Arizona state of counties

Data Source

Reading data from AZ counties data from {tigris} and cleaning up column names using clean_names()

# Download the shapefile for Arizona counties
az_map <- states(cb = TRUE, progress = FALSE) %>%
  janitor::clean_names() %>%
  filter(name == "Arizona")

rivers <- st_read(here("data", "azRivers", "Major_Rivers.shp")) %>% 
  clean_names() %>%
  st_transform(crs = st_crs(az_map))
Reading layer `Major_Rivers' from data source 
  `/Users/gchism/Desktop/posit-table-2024/data/azRivers/Major_Rivers.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 4347 features and 17 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: 141387.6 ymin: 3466584 xmax: 683030.4 ymax: 4098290
Projected CRS: NAD83 / UTM zone 12N
az_rivers_gila <- subset(rivers, name == "Gila River")
az_rivers_colorado <- subset(rivers, name == "Colorado River")
az_rivers_little_colorado <- subset(rivers, name == "Little Colorado River")

lakes <- st_read(here("data", "azLakes", "Major_Lakes.shp")) %>% 
  clean_names() %>%
  st_transform(crs = st_crs(az_map))
Reading layer `Major_Lakes' from data source 
  `/Users/gchism/Desktop/posit-table-2024/data/azLakes/Major_Lakes.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 176 features and 17 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 145017.4 ymin: 3473209 xmax: 681899.2 ymax: 4094984
Projected CRS: NAD83 / UTM zone 12N
centralAZ <- st_read(here("data", "Cen_AZ_Proj", "Cen_AZ_Proj.shp")) %>% 
  clean_names() %>%
  st_transform(crs = st_crs(az_map))
Reading layer `Cen_AZ_Proj' from data source 
  `/Users/gchism/Desktop/posit-table-2024/data/Cen_AZ_Proj/Cen_AZ_Proj.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 61 features and 10 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: 214278.4 ymin: 3540366 xmax: 500705.5 ymax: 3798718
Projected CRS: NAD83 / UTM zone 12N

Arizona Counties

Plotting AZ counties from the shapefile above. We have some components involved in the code which are mentioned below:

  • Using geom_sf() to plot the map
  • Using geom_label_repel() to create labels for each county

4 - Arizona state of tribes

Data Source

Reading .shp data from the data folder using st_read the {sp} package. There are some noteworthy steps:

  • Set the crs to 4269, which is standard for US Census data
  • Transform the crs to the same as the az_counties_pop to ensure its standardized.
tribal_lands <- st_read(here("data", "azTribes", "American_Indian_Reservations_in_Arizona.shp")) %>% 
  clean_names()
Reading layer `American_Indian_Reservations_in_Arizona' from data source 
  `/Users/gchism/Desktop/posit-table-2024/data/azTribes/American_Indian_Reservations_in_Arizona.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 28 features and 18 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -114.814 ymin: 31.50811 xmax: -109.0452 ymax: 37.00399
Geodetic CRS:  WGS 84
tribal_lands <- st_set_crs(tribal_lands, 4269)
tribal_lands <- st_transform(tribal_lands, crs = st_crs(az_map))

tribal_lands <- tribal_lands %>%
  mutate(
    tribe = case_when(
      tribe = str_detect(name, "Ak-Chin") ~ "Ak-Chin Indian Community",
      tribe = str_detect(name, "Hopi") ~ "Hopi Tribe",
      tribe = str_detect(name, "Hualapai") ~ "Hualapai Tribe",
      tribe = str_detect(name, "Navajo") ~ "Navajo Nation",
      tribe = str_detect(name, "Pascua") ~ "Pascua Yaqui Tribe",    
      tribe = str_detect(name, "Tohono") ~ "Tohono O'odham Nation",
      tribe = str_detect(name, "Tonto Apache") ~ "Tonto Apache Tribe",
      tribe = str_detect(name, "Yavapai-Apache") ~ "Yavapai-Apache Tribe",
      TRUE ~ name
    ),
    url = case_when(
      tribe == "Ak-Chin Indian Community" ~ "https://ak-chin.nsn.us/",
      tribe == "Cocopah Indian Tribe" ~ "https://www.cocopah.com/",
      tribe == "Colorado River Indian Tribes" ~ "https://www.crit-nsn.gov/",
      tribe == "Fort McDowell Yavapai Nation" ~ "https://fmyn.org/",
      tribe == "Fort Mojave Indian Tribe" ~ "https://www.fortmojaveindiantribe.com/",
      tribe == "Gila River Indian Community" ~ "https://www.gilariver.org/",
      tribe == "Havasupai Tribe" ~ "https://theofficialhavasupaitribe.com/",
      tribe == "Hopi Tribe" ~ "https://www.hopi-nsn.gov/",
      tribe == "Hualapai Tribe" ~ "https://hualapai-nsn.gov/",
      tribe == "Kaibab-Paiute Tribe" ~ "https://www.kaibabpaiute-nsn.gov/",
      tribe == "Navajo Nation" ~ "https://www.navajo-nsn.gov/",
      tribe == "Pascua Yaqui Tribe" ~ "https://www.pascuayaqui-nsn.gov/",
      tribe == "Pueblo of Zuni" ~ "https://www.ashiwi.org/",
      tribe == "Quechan Tribe" ~ "https://www.quechantribe.com/index.html",
      tribe == "Salt River Pima-Maricopa Indian Community" ~ "https://www.srpmic-nsn.gov/",
      tribe == "San Carlos Apache Tribe" ~ "https://itcaonline.com/member-tribes/san-carlos-apache-tribe/",
      tribe == "Tohono O'odham Nation" ~ "http://www.tonation-nsn.gov/",
      tribe == "Tonto Apache Tribe" ~ "https://itcaonline.com/member-tribes/tonto-apache-tribe/",
      tribe == "White Mountain Apache Tribe" ~ "http://www.wmat.us/",
      tribe == "Yavapai-Apache Tribe" ~ "https://yavapai-apache.org/",
      tribe == "Yavapai-Prescott Indian Tribe" ~ "https://ypit.com/",
      TRUE ~ NA
    ),
    pop = case_when(
      tribe == "Ak-Chin Indian Community" ~ 1450,
      tribe == "Cocopah Indian Tribe" ~ 1158,
      tribe == "Colorado River Indian Tribes" ~ 8385,
      tribe == "Fort McDowell Yavapai Nation" ~ 1006,
      tribe == "Fort Mojave Indian Tribe" ~ 1572,
      tribe == "Gila River Indian Community" ~ 12179,
      tribe == "Havasupai Tribe" ~ 730,
      tribe == "Hopi Tribe" ~ 7895,
      tribe == "Hualapai Tribe" ~ 1738,
      tribe == "Kaibab-Paiute Tribe" ~ 249,
      tribe == "Navajo Nation" ~ 166545,
      tribe == "Pascua Yaqui Tribe" ~ 3678,
      tribe == "Pueblo of Zuni" ~ 8134,
      tribe == "Quechan Tribe" ~ 1536,
      tribe == "Salt River Pima-Maricopa Indian Community" ~ 5949,
      tribe == "San Carlos Apache Tribe" ~ 10204,
      tribe == "Tohono O'odham Nation" ~ 10052,
      tribe == "Tonto Apache Tribe" ~ 102,
      tribe == "White Mountain Apache Tribe" ~ 14620,
      tribe == "Yavapai-Apache Tribe" ~ 1085,
      tribe == "Yavapai-Prescott Indian Tribe" ~ 551,
      TRUE ~ NA
    ),
    flag_url = case_when(
      tribe == "Ak-Chin Indian Community" ~ "https://upload.wikimedia.org/wikipedia/commons/7/7b/Flag_of_the_Ak-Chin_Indian_Community.svg",
      tribe == "Cocopah Indian Tribe" ~ "https://upload.wikimedia.org/wikipedia/commons/7/78/Flag_of_the_Cocopah_Reservation.svg",
      tribe == "Colorado River Indian Tribes" ~ "https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_the_Colorado_River_Indian_Tribes.svg",
      tribe == "Fort McDowell Yavapai Nation" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Fort_McDowell_Yavapai_Nation.svg",
      tribe == "Fort Mojave Indian Tribe" ~ NA,
      tribe == "Gila River Indian Community" ~ "https://upload.wikimedia.org/wikipedia/commons/0/08/Flag_of_the_Gila_River_Indian_Community.svg",
      tribe == "Havasupai Tribe" ~ NA,
      tribe == "Hopi Tribe" ~ "https://upload.wikimedia.org/wikipedia/commons/7/74/Flag_of_the_Hopi_Reservation.svg",
      tribe == "Hualapai Tribe" ~ NA,
      tribe == "Kaibab-Paiute Tribe" ~ NA,
      tribe == "Navajo Nation" ~ "https://upload.wikimedia.org/wikipedia/commons/0/0c/Navajo_flag.svg",
      tribe == "Pascua Yaqui Tribe" ~ "https://upload.wikimedia.org/wikipedia/commons/4/41/Flag_of_the_Pascua_Yaqui_Tribe_of_Arizona.svg",
      tribe == "Pueblo of Zuni" ~ NA,
      tribe == "Quechan Tribe" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Quechan_tribal_seal.svg",
      tribe == "Salt River Pima-Maricopa Indian Community" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Srpmic.svg",
      tribe == "San Carlos Apache Tribe" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Flag_of_the_San_Carlos_Apache_Tribe.svg",
      tribe == "Tohono O'odham Nation" ~ "https://upload.wikimedia.org/wikipedia/commons/9/9e/Flag_of_the_Tohono_O%27odham_Nation.svg",
      tribe == "Tonto Apache Tribe" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Flag_of_the_Tonto_Apache_Tribe.svg",
      tribe == "White Mountain Apache Tribe" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/White_Mountain_Apache_Tribe.svg",
      tribe == "Yavapai-Apache Tribe" ~ "https://raw.githubusercontent.com/Gchism94/posit-table-2024/main/images/Flag_of_the_Yavapai-Apache_Nation.svg",
      tribe == "Yavapai-Prescott Indian Tribe" ~ "https://upload.wikimedia.org/wikipedia/commons/4/49/Flag_of_the_Yavapai-Prescott_Tribe.svg",
      TRUE ~ ""
    ),
    name = ifelse(name == "Tohono O’odham Nation", "Tohono O'odham Nation", name),
    number = dense_rank(name)) 

water_rights <- tribble(
  ~tribe, ~claim, ~recognized, ~resolved,
  "Salt River Pima-Maricopa Indian Community", 1949, 1988, "Fully",
  "Cocopah Indian Tribe", 1953, 1963, "Adjudicated",
  "Colorado River Indian Tribes", 1953, 1963, "Adjudicated",
  "Fort Mojave Indian Tribe", 1953, 1963, "Adjudicated",
  "Quechan Tribe", 1953, 1963, "Adjudicated",
  "Ak-Chin Indian Community", 1974, 1978, "Fully",
  "Tohono O'odham Nation", 1975, 1982, "Partially",
  "Gila River Indian Community", 1976, 2005, "Fully",
  "Yavapai-Prescott Indian Tribe", 1978, 1995, "Fully",
  "White Mountain Apache Tribe", 1979, 2010, "Fully",
  "Fort McDowell Yavapai Nation", 1979, 1990, "Fully",
  "Pueblo of Zuni", 1979, 2003, "Fully",
  "Yavapai-Apache Tribe", 1979, NA, "Unresolved",
  "San Carlos Apache Tribe", 1979, 1999, "Partially",
  "Hualapai Tribe", 1985, 2014, "Fully",
  "Hopi Tribe", 1985, NA, "Unresolved",
  "Tonto Apache Tribe", 1985, NA, "Unresolved",
  "Navajo Nation", 1985, NA, "Unresolved",
  "Pascua Yaqui Tribe", 1987, NA, "Unresolved",
  "San Juan Southern Paiute Tribe", 1991, NA, "Unresolved",
  "Havasupai Tribe", 2016, NA, "Partially",
  "Kaibab-Paiute Tribe", NA, NA, "Unresolved"
)

tribal_lands_water <- 
  tribal_lands %>%
  left_join(water_rights) %>%
  mutate(years = ifelse(is.na(recognized), 2024 - claim, 
                              recognized - claim),
         res_color = case_when(
           resolved == "Fully" | resolved == "Adjudicated" ~ "#127852",
           resolved == "Partially" ~ "goldenrod",
           resolved == "Unresolved" ~ "#C40233",
           TRUE ~ "gray"
         )) 
tribal_lands_water_reduced <- tribal_lands_water %>%
  st_drop_geometry() %>%
  select(tribe, url) %>%
  distinct()

tribal_lands_water_map <- 
  tribal_lands_water %>%
  group_by(tribe) %>%
  summarize(geometry = st_union(geometry)) %>%
  left_join(tribal_lands_water_reduced)

tribal_map_all <- ggplot(az_map) +
  geom_sf(fill = "#E7E4D9") +
  geom_sf(data = rivers, color = "#8ca7c0", linewidth = 0.5) +
  geom_sf(data = centralAZ, color = "#98A68F", linewidth = 0.5) +
  geom_sf(data = lakes, fill = "#8ca7c0", color = "#8ca7c0", size = 1) +
  geom_sf(data = tribal_lands_water_map, aes(fill = "#BA8172"), alpha = 0.5, color = "gray85", linewidth = 0.15) +
  scale_fill_identity() +
  coord_sf(clip = "off")

tribe_plot_fcn <- function(tribal_lands_water_map, az_map, rivers, centralAZ, lakes) {
  
  # Transform the coordinate systems to a common CRS
  tribal_mer <- tribal_lands_water_map %>% st_transform(crs = 3857)
  az_map_mer <- az_map %>% st_transform(crs = 3857)
  rivers_mer <- rivers %>% st_transform(crs = 3857)
  centralAZ_mer <- centralAZ %>% st_transform(crs = 3857)
  lakes_mer <- lakes %>% st_transform(crs = 3857)
  
  # Ensure geometries are valid
  tribal_mer <- st_make_valid(tribal_mer)
  
  # Calculate the bounding box for each tribe area
  tribe_bbox <- st_bbox(tribal_mer) %>% st_as_sfc()
  tribe_name <- tribal_lands_water_map$tribe
  
  # Create the plot
  gg <- 
    (ggplot() +
       geom_sf(data = az_map_mer, fill = "#E7E4D9") +
       geom_sf(data = rivers_mer, color = "#8ca7c0", linewidth = 0.5) +
       geom_sf(data = centralAZ_mer, color = "#98A68F", linewidth = 0.5) +
       geom_sf(data = lakes_mer, fill = "#8ca7c0", color = "#8ca7c0", size = 1) +
       geom_sf(data = tribal_mer, aes(fill = "#BA8172"), alpha = 0.5, color = "gray85", linewidth = 0.15) +
       scale_fill_identity() +
       coord_sf(
         xlim = st_coordinates(tribe_bbox)[c(1,3),1], # min & max of x values
         ylim = st_coordinates(tribe_bbox)[c(2,4),2]) + # min & max of y values
       theme_void() +
       theme(
         legend.position = 'none',
         panel.background = element_rect(fill = 'transparent', color = NA),
         plot.background = element_rect(fill = 'transparent', color = NA)))
  
  # Return the plot in a tibble
  result <- tibble(tribe = tribe_name, plot = list(gg))
  
  return(result)
}

# Apply the function to each group and integrate into reactable
tribal_maps <- 
  map_dfr(
    .x = group_split(tribal_lands_water_map, tribe),
    .f = ~tribe_plot_fcn(tribal_lands_water_map = .x, az_map = az_map, rivers = rivers, centralAZ = centralAZ, lakes = lakes)
  )

Arizona Indigenous Tribal Boundaries

Plotting AZ Indigenous Tribal boundaries from the az counties shapefile and the shapefile from AZGeo Data. There are a few noteworthy steps:

  1. Utilizing two geom_sf() arguments - i. for the AZ counties, ii. for the indigenous regions.
  2. Utilizing geom_label_repel() with the top 5 largest tribal regions.
tribal_map <-
  ggplot(az_map) +
  geom_sf(fill = "#E7E4D9") +
  geom_sf(data = rivers, color = "#8ca7c0", linewidth = 0.5) +
  geom_sf(data = centralAZ, color = "#98A68F", linewidth = 0.5) +
  geom_sf(data = lakes, fill = "#8ca7c0", color = "#8ca7c0", size = 1) +
  geom_sf(data = tribal_lands_water, aes(fill = "#BA8172"), alpha = 0.5, color = "gray85", linewidth = 0.15) +
  geom_label_repel_interactive(
    data = tribal_lands_water,
    aes(label = number, geometry = geometry, 
        tooltip = paste0("<a href='", url, "'>", name, "</a>\n"),
        onclick = paste0('window.open("', url , '")')),
    stat = "sf_coordinates",
    min.segment.length = 0,
    force = 16) +
  scale_fill_identity(guide = "legend", labels = "Federally Recognized Tribal\nReservations and Trust Land") +
  labs(title = "Federally Recognized Tribal Reservations and Trust Land\nin Arizona",
       x = "Longitude",
       y = "Latitude",
       caption = "Source: Shapefile obtained using {tigris} R package, v2.0.1\nIndigenous Tribe Shapefile obtained from AZGeo Data",
       fill = NULL) +
  coord_sf(clip = "off") +
  theme(plot.title.position = "plot",
        legend.key.size = unit(1, "cm"),
        legend.position = "left",
        legend.justification = "top",
        plot.caption = element_text(color = "gray80"))

girafe(ggobj = tribal_map)
# Install & load required packages
if (!require(pacman)) install.packages('pacman')

p_load(here,          # for standardized file paths
       htmltools,     # for saving HTML objects
       reactable,     # for HTML tables
       reactablefmtr, # for easier formatting reactable tables
       tidyverse)     # for data wrangling

tribal_lands_water_agg <- 
  tribal_lands_water %>%
  # Group data by columns
  group_by(tribe, url, years, flag_url, resolved, res_color) %>%
  # Create a percentage column, rounded to two decimal points
  summarise(
    combined_names = if (n_distinct(name) > 1) 
      {paste("+", name[name != tribe], collapse = ", <br>")
      } 
    else {
      ""
    },
    land = sum(aland) / (1000^2),
    water = sum(awater) / (1000^2),
    pop = sum(pop),
    .groups = "drop") |>
  mutate(combined_names = ifelse(combined_names != "",
                                 paste0("<div style='font-size: 0.6rem; color: #777;'>", combined_names,
                                        "</div>"),
                                 combined_names))

# Create a styled header
header_content <- tags$div(
  tags$link(
    href = "https://fonts.googleapis.com/css2?family=Bungee&family=Montserrat:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap", 
    rel = "stylesheet"
  ),
  tags$div(
    tags$div(
      "Waiting for Water", 
      style = css(
        'font-size' = '50pt', 
        'font-weight' = 'bold', 
        'font-family' = 'Bungee', 
        'text-align' = 'left',
        'margin-bottom' = 0,
        'padding-left' = '10px',
        'vertical-align' = 'middle'
      )
    ),
    tags$div(
      "Investigating Arizona Tribal Water Rights", 
      style = css(
        'font-family' = 'Montserrat',
        'margin-bottom' = 0,
        'margin-top' = 0,
        'font-size' = '28pt',
        'text-align' = 'left',
        color = '#8C8C8C',
        'padding-left' = '10px'
      )
    ),
    tags$div(
      "...or a lack thereof", 
      style = css(
        'font-family' = 'Montserrat',
        'margin-bottom' = 0,
        'margin-top' = 0,
        'font-size' = '18pt',
        'text-align' = 'left',
        color = '#8C8C8C',
        'padding-left' = '10px'
      )
    ),
    style = css(width = '70%')
  ),
  tags$div(
    plotTag(
      tribal_map_all,
      alt = "Map of all Arizona Tribes",
      height = 200
    ),
    style = css(width = '30%')
  ),
  style = css(
    width = '1250px',
    display = 'inline-flex',
    'align-items' = 'center',
    'justify-content' = 'space-between'
  )
)

footer_content <- 
  tags$div(
    tags$link(
      href = "https://fonts.googleapis.com/css2?family=Bungee&family=Montserrat:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap", 
      rel = "stylesheet"
    ),
    tags$div(
      tags$sup("*"), 
      "Kaibab Band of Paiute Indians has not filed a water claim yet.",
      tags$br(),
      tags$sup("1"), 
      "The Winters Doctrine, from the 1908 Supreme Court case ",
      tags$a(
        href = "https://en.wikipedia.org/wiki/Winters_v._United_States#:~:text=Winters%20v.%20United%20States%2C%20207%20U.S.%20564%20%281908%29%2C,cases%20where%20the%20rights%20were%20not%20clear.%20",
        target = "_blank",
        tags$i("Winters v. United States")
      ),
      ", established that Native American tribes have reserved water rights when reservations are created. These rights are considered to have a priority date corresponding to the establishment date of the reservation, making them senior to many other water rights.",
      tags$br(),
      tags$sup("2"),
      "Adjudicated Water Rights resulted from the set of United States Supreme Court cases.",
      tags$a(
        href = "https://en.wikipedia.org/wiki/Arizona_v._California",
        target = "_blank",
        tags$i("Arizona v. California")
      ),
      ", which all deal with disputes over water distribution from the Colorado River between the states of Arizona and California.",
      style = css(
        display = 'inline-block',
        'text-align' = 'left',
        'font-family' = 'Montserrat',
        color = 'black', 
        'font-size' = '9pt',
        'border-bottom-style' = 'solid',
        'border-top-style' = 'solid',
        width = '1250px',
        'padding-bottom' = '8px',
        'padding-top' = '8px',
        'padding-left' = '10px',
        'border-color' = '#DADADA'
      )
    ),
    tags$div(
      "Data Sources: Wikipedia, US Census Bureau, ProPublica.org, and AZ Geo Data Hub | ",
      shiny::icon("github"), 
      tags$a("Gchism94", href = "https://github.com/Gchism94", target = "_blank"),
      style = css(
        display = 'inline-block', 
        'vertical-align' = 'middle',
        'text-align' = 'left',
        'font-family' = 'Montserrat', 
        color = '#8C8C8C', 
        'font-size' = '10pt', 
        width = '1250px', 
        'padding-top' = '8px', 
        'padding-left' = '10px'
      )
    )
  )

# HTML tables for UA position and UA department affiliation
tribes_table <- 
  tribal_lands_water_agg %>%
    st_drop_geometry() %>%
    mutate(tribe = ifelse(tribe == "Kaibab-Paiute Tribe",
                          paste0("<a href='", url, "'>", tribe, "</a>", "*", "<br>", combined_names),
                          paste0("<a href='", url, "'>", tribe, "</a>", "<br>", combined_names)),
           map = NA
           ) %>%
    select(-c(url)) %>%
    relocate(flag_url, .before = years) %>%
    relocate(tribe, .before = flag_url) %>%
    relocate(resolved, .after = years) %>%
    relocate(pop, .after = resolved) %>%
  # Reactable argument
  reactable(
    # Clean theme with base font size 16pt
    theme = reactableTheme(
      style = list(fontSize = "1rem",
                   fontFamily = "Montserrat, sans-serif")
    ),
    width = 1250,
    # Default table sort by years column
    defaultSorted = "years",
    # Default sort order descending
    defaultSortOrder = "desc",
    defaultColDef = colDef(
      vAlign = "center",
      align = "center",
      headerVAlign = "center",
      html = TRUE,
      ),
    # Columns list
    columns = list(
      # tribe column
      tribe = colDef(maxWidth = 250,
                    name = "Tribe",
                    align = "left",
                    html = TRUE),
      
      combined_names = colDef(show = FALSE), 
      
      flag_url = colDef(name = '',
                        maxWidth = 65,
                        sortable = FALSE,
                        style = background_img(height = "100%", width = "95%")
        ),
      # pop column
      pop = colDef(maxWidth = 130,
                   name = "Population",
                   align = 'center',
                    cell = color_tiles(
                      data = tribal_lands_water_agg,
                      number_fmt = scales::comma_format(accuracy = 1),
                      colors = "gray50",
                      text_color = "white"
                  )
                  ),
      
      # land column
      land = colDef(maxWidth = 100,
                    name = "Land",
                    align = 'center',
                    cell = color_tiles(
                      data = .,
                      number_fmt = scales::comma_format(accuracy = 1),
                      colors = paletteer::paletteer_c("ggthemes::Classic Area-Brown", 30)
                    ),
                    html = TRUE,
                    header = JS('function(column) {
        return column.name + `<div style="color: #737373; font-size: 0.8rem;">km<sup>2</sup></div>`
      }')
      ),
      
      # water column
      water = colDef(maxWidth = 100,
                     name = "Water",
                     align = 'center',
                     cell = color_tiles(
                      data = .,
                      number_fmt = scales::comma_format(accuracy = 1),
                      colors = RColorBrewer::brewer.pal(5, 'Blues')
                     ),
                    html = TRUE,
                    header = JS('function(column) {
        return column.name + `<div style="color: #737373; font-size: 0.8rem;">km<sup>2</sup></div>`
      }')
      ),
      
      # years column
      years = colDef(
        name = 'Years until water rights after filing<sup>1</sup>',
        align = 'left',
        maxWidth = 325,
        html = TRUE,
        cell = data_bars(
          data = .,
          fill_color = MetBrewer::met.brewer('Tsimshian', type = "continuous", direction = -1),
          text_position = 'none',
          box_shadow = TRUE,
          max_value = max(tribal_lands_water_agg$years, na.rm = TRUE),
          icon = 'droplet',
          bias = 1.5,
          bar_height = 4,
          background = 'transparent',
          round_edges = TRUE,
          tooltip = TRUE,
        )
      ),
      resolved = colDef(
        name = "Water Rights <sup>2</sup>",
        minWidth = 65,
        html = TRUE,
        header = JS('function(column) {
        return column.name + `<div style="color: #737373; font-size: 0.8rem;">Status</div>`
      }'),
        cell = pill_buttons(
          data = .,
          color_ref = 'res_color',
          box_shadow = TRUE
        )
        ),
      res_color = colDef(show = FALSE),
      map = colDef(
        name = "Tribal Map",
        cell = function(value, index){
          htmltools::plotTag(
            tribal_maps$plot[[index]],
            alt = 'plots',
            height = 50,
            width = 50,
            deviceArgs = list(bg = 'transparent'))
          },
        width = 150
      )
    )
    )

  # Combine the header and the reactable in a single HTML structure
full_page <- tags$div(
  header_content,
  tribes_table,
  footer_content,
  style = css('width' = '100%')
)

# Render the full page
htmltools::browsable(full_page)
Waiting for Water
Investigating Arizona Tribal Water Rights
...or a lack thereof
Map of all Arizona Tribes
* Kaibab Band of Paiute Indians has not filed a water claim yet.
1 The Winters Doctrine, from the 1908 Supreme Court case Winters v. United States , established that Native American tribes have reserved water rights when reservations are created. These rights are considered to have a priority date corresponding to the establishment date of the reservation, making them senior to many other water rights.
2 Adjudicated Water Rights resulted from the set of United States Supreme Court cases. Arizona v. California , which all deal with disputes over water distribution from the Colorado River between the states of Arizona and California.
Data Sources: Wikipedia, US Census Bureau, ProPublica.org, and AZ Geo Data Hub | Gchism94
# Save interactive HTML table
#save_html(positionRegistTable, "reports/tables/dsiRegistrantPosition.html")